Imports MySql.Data.MySqlClient
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe
Imports System.Data.OracleClient
Imports System.Data
Imports DTO
Public Class NhanvienDao
    Inherits AbstractDao
#Region "New"
    Public Sub New(ByVal connection As KetNoiDto)
        MyBase.New(connection)
    End Sub
    Public Sub New(ByVal ma As Integer, ByVal connection As KetNoiDto)
        MyBase.New("Nhanvien", "select * from Nhanvien where MaNV=" & ma & "", connection)
    End Sub
#End Region
    Public Sub Them(ByVal Dto As Nhanviendto)
        Dim strsql As String
        strsql = "Insert into Nhanvien(NVSP,TenNV,TenHT,Chucvu,Donvi,Quyen,CardNo,Ngaysinh,Gioitinh,Diachi,CMND,Ngayvaolam,Hinh,Trangthai,Ghichu) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                Dim cmd As New OleDbCommand(strsql, Ket_noi_Access)
                cmd.Parameters.Add("@NVSP", OleDbType.VarWChar)
                cmd.Parameters.Add("@TenNV", OleDbType.VarWChar)
                cmd.Parameters.Add("@TenHT", OleDbType.VarWChar)
                cmd.Parameters.Add("@Chucvu", OleDbType.Integer)
                cmd.Parameters.Add("@Donvi", OleDbType.Integer)
                cmd.Parameters.Add("@Quyen", OleDbType.Integer)
                cmd.Parameters.Add("@CardNo", OleDbType.VarWChar)
                cmd.Parameters.Add("@Ngaysinh", OleDbType.date)
                cmd.Parameters.Add("@Gioitinh", OleDbType.VarWChar)
                cmd.Parameters.Add("@Diachi", OleDbType.VarWChar)
                cmd.Parameters.Add("@CMND", OleDbType.VarWChar)
                cmd.Parameters.Add("@Ngayvaolam", OleDbType.date)
                cmd.Parameters.Add("@Hinh", OleDbType.VarWChar)
                cmd.Parameters.Add("@Trangthai", OleDbType.Integer)
                cmd.Parameters.Add("@Ghichu", OleDbType.VarWChar)
                cmd.Parameters("@NVSP").Value = Dto.NVSP
                cmd.Parameters("@TenNV").Value = Dto.TenNV
                cmd.Parameters("@TenHT").Value = Dto.TenHT
                cmd.Parameters("@Chucvu").Value = Dto.Chucvu
                cmd.Parameters("@Donvi").Value = Dto.Donvi
                cmd.Parameters("@Quyen").Value = Dto.Quyen
                cmd.Parameters("@CardNo").Value = Dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = Dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = Dto.Gioitinh
                cmd.Parameters("@Diachi").Value = Dto.Diachi
                cmd.Parameters("@CMND").Value = Dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = Dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = Dto.Hinh
                cmd.Parameters("@Trangthai").Value = Dto.Trangthai
                cmd.Parameters("@Ghichu").Value = Dto.Ghichu
                cmd.ExecuteNonQuery()
                strsql = "Select @@IDENTITY"
                cmd = New OleDbCommand(strsql, Ket_noi_Access)
                Dto.MaNV = cmd.ExecuteScalar()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strsql = "Insert into Nhanvien(NVSP,TenNV,TenHT,Chucvu,Donvi,Quyen,CardNo,Ngaysinh,Gioitinh,Diachi,CMND,Ngayvaolam,Hinh,Trangthai,Ghichu) values (@NVSP,@TenNV,@TenHT,@Chucvu,@Donvi,@Quyen,@CardNo,@Ngaysinh,@Gioitinh,@Diachi,@CMND,@Ngayvaolam,@Hinh,@Trangthai,@Ghichu)"
                Dim cmd As New SqlCommand(strsql, Ket_noi_Sql)
                cmd.Parameters.Add("@NVSP", SqlDbType.NVarChar)
                cmd.Parameters.Add("@TenNV", SqlDbType.NVarChar)
                cmd.Parameters.Add("@TenHT", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Chucvu", SqlDbType.Int)
                cmd.Parameters.Add("@Donvi", SqlDbType.Int)
                cmd.Parameters.Add("@Quyen", SqlDbType.Int)
                cmd.Parameters.Add("@CardNo", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Ngaysinh", SqlDbType.DateTime)
                cmd.Parameters.Add("@Gioitinh", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Diachi", SqlDbType.NVarChar)
                cmd.Parameters.Add("@CMND", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Ngayvaolam", SqlDbType.DateTime)
                cmd.Parameters.Add("@Hinh", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Trangthai", SqlDbType.Int)
                cmd.Parameters.Add("@Ghichu", SqlDbType.NVarChar)
                cmd.Parameters("@NVSP").Value = Dto.NVSP
                cmd.Parameters("@TenNV").Value = Dto.TenNV
                cmd.Parameters("@TenHT").Value = Dto.TenHT
                cmd.Parameters("@Chucvu").Value = Dto.Chucvu
                cmd.Parameters("@Donvi").Value = Dto.Donvi
                cmd.Parameters("@Quyen").Value = Dto.Quyen
                cmd.Parameters("@CardNo").Value = Dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = Dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = Dto.Gioitinh
                cmd.Parameters("@Diachi").Value = Dto.Diachi
                cmd.Parameters("@CMND").Value = Dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = Dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = Dto.Hinh
                cmd.Parameters("@Trangthai").Value = Dto.Trangthai
                cmd.Parameters("@Ghichu").Value = Dto.Ghichu
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.SqlCe
                strsql = "Insert into Nhanvien(NVSP,TenNV,TenHT,Chucvu,Donvi,Quyen,CardNo,Ngaysinh,Gioitinh,Diachi,CMND,Ngayvaolam,Hinh,Trangthai,Ghichu) values (@NVSP,@TenNV,@TenHT,@Chucvu,@Donvi,@Quyen,@CardNo,@Ngaysinh,@Gioitinh,@Diachi,@CMND,@Ngayvaolam,@Hinh,@Trangthai,@Ghichu)"
                Dim cmd As New SqlCeCommand(strsql, Ket_noi_SqlCe)
                cmd.Parameters("@NVSP").Value = Dto.NVSP
                cmd.Parameters("@TenNV").Value = Dto.TenNV
                cmd.Parameters("@TenHT").Value = Dto.TenHT
                cmd.Parameters("@Chucvu").Value = Dto.Chucvu
                cmd.Parameters("@Donvi").Value = Dto.Donvi
                cmd.Parameters("@Quyen").Value = Dto.Quyen
                cmd.Parameters("@CardNo").Value = Dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = Dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = Dto.Gioitinh
                cmd.Parameters("@Diachi").Value = Dto.Diachi
                cmd.Parameters("@CMND").Value = Dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = Dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = Dto.Hinh
                cmd.Parameters("@Trangthai").Value = Dto.Trangthai
                cmd.Parameters("@Ghichu").Value = Dto.Ghichu
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strsql = "Insert into Nhanvien(NVSP,TenNV,TenHT,Chucvu,Donvi,Quyen,CardNo,Ngaysinh,Gioitinh,Diachi,CMND,Ngayvaolam,Hinh,Trangthai,Ghichu) values (@NVSP,@TenNV,@TenHT,@Chucvu,@Donvi,@Quyen,@CardNo,@Ngaysinh,@Gioitinh,@Diachi,@CMND,@Ngayvaolam,@Hinh,@Trangthai,@Ghichu)"
                Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
                cmd.Parameters("@NVSP").Value = Dto.NVSP
                cmd.Parameters("@TenNV").Value = Dto.TenNV
                cmd.Parameters("@TenHT").Value = Dto.TenHT
                cmd.Parameters("@Chucvu").Value = Dto.Chucvu
                cmd.Parameters("@Donvi").Value = Dto.Donvi
                cmd.Parameters("@Quyen").Value = Dto.Quyen
                cmd.Parameters("@CardNo").Value = Dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = Dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = Dto.Gioitinh
                cmd.Parameters("@Diachi").Value = Dto.Diachi
                cmd.Parameters("@CMND").Value = Dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = Dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = Dto.Hinh
                cmd.Parameters("@Trangthai").Value = Dto.Trangthai
                cmd.Parameters("@Ghichu").Value = Dto.Ghichu
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strsql = "Insert into Nhanvien(NVSP,TenNV,TenHT,Chucvu,Donvi,Quyen,CardNo,Ngaysinh,Gioitinh,Diachi,CMND,Ngayvaolam,Hinh,Trangthai,Ghichu) values (@NVSP,@TenNV,@TenHT,@Chucvu,@Donvi,@Quyen,@CardNo,@Ngaysinh,@Gioitinh,@Diachi,@CMND,@Ngayvaolam,@Hinh,@Trangthai,@Ghichu)"
                Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
                cmd.Parameters.Add("@NVSP", MySqlDbType.String)
                cmd.Parameters.Add("@TenNV", MySqlDbType.String)
                cmd.Parameters.Add("@TenHT", MySqlDbType.String)
                cmd.Parameters.Add("@Chucvu", MySqlDbType.Int32)
                cmd.Parameters.Add("@Donvi", MySqlDbType.Int32)
                cmd.Parameters.Add("@Quyen", MySqlDbType.Int32)
                cmd.Parameters.Add("@CardNo", MySqlDbType.String)
                cmd.Parameters.Add("@Ngaysinh", MySqlDbType.DateTime)
                cmd.Parameters.Add("@Gioitinh", MySqlDbType.String)
                cmd.Parameters.Add("@Diachi", MySqlDbType.String)
                cmd.Parameters.Add("@CMND", MySqlDbType.String)
                cmd.Parameters.Add("@Ngayvaolam", MySqlDbType.DateTime)
                cmd.Parameters.Add("@Hinh", MySqlDbType.String)
                cmd.Parameters.Add("@Trangthai", MySqlDbType.Int32)
                cmd.Parameters.Add("@Ghichu", MySqlDbType.String)
                cmd.Parameters("@NVSP").Value = Dto.NVSP
                cmd.Parameters("@TenNV").Value = Dto.TenNV
                cmd.Parameters("@TenHT").Value = Dto.TenHT
                cmd.Parameters("@Chucvu").Value = Dto.Chucvu
                cmd.Parameters("@Donvi").Value = Dto.Donvi
                cmd.Parameters("@Quyen").Value = Dto.Quyen
                cmd.Parameters("@CardNo").Value = Dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = Dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = Dto.Gioitinh
                cmd.Parameters("@Diachi").Value = Dto.Diachi
                cmd.Parameters("@CMND").Value = Dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = Dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = Dto.Hinh
                cmd.Parameters("@Trangthai").Value = Dto.Trangthai
                cmd.Parameters("@Ghichu").Value = Dto.Ghichu
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub Xoa(ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Delete From Nhanvien Where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@ma", OleDbType.Integer)
                cmd.Parameters("@ma").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Delete From Nhanvien Where MaNV=" & ma & ""
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.SqlCe
                strSQL = "Delete From Nhanvien Where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Delete From Nhanvien Where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Delete From Nhanvien Where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub sua(ByVal dto As Nhanviendto)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set NVSP=? ,TenNV=? ,TenHT=? ,Chucvu=? ,Donvi=? ,Quyen=? ,CardNo=? ,Ngaysinh=? ,Gioitinh=? ,Diachi=? ,CMND=? ,Ngayvaolam=? ,Hinh=? ,Trangthai=? ,Ghichu= ? where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@NVSP", OleDbType.VarWChar)
                cmd.Parameters.Add("@TenNV", OleDbType.VarWChar)
                cmd.Parameters.Add("@TenHT", OleDbType.VarWChar)
                cmd.Parameters.Add("@Chucvu", OleDbType.Integer)
                cmd.Parameters.Add("@Donvi", OleDbType.Integer)
                cmd.Parameters.Add("@Quyen", OleDbType.Integer)
                cmd.Parameters.Add("@CardNo", OleDbType.VarWChar)
                cmd.Parameters.Add("@Ngaysinh", OleDbType.date)
                cmd.Parameters.Add("@Gioitinh", OleDbType.VarWChar)
                cmd.Parameters.Add("@Diachi", OleDbType.VarWChar)
                cmd.Parameters.Add("@CMND", OleDbType.VarWChar)
                cmd.Parameters.Add("@Ngayvaolam", OleDbType.date)
                cmd.Parameters.Add("@Hinh", OleDbType.VarWChar)
                cmd.Parameters.Add("@Trangthai", OleDbType.Integer)
                cmd.Parameters.Add("@Ghichu", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@NVSP").Value = dto.NVSP
                cmd.Parameters("@TenNV").Value = dto.TenNV
                cmd.Parameters("@TenHT").Value = dto.TenHT
                cmd.Parameters("@Chucvu").Value = dto.Chucvu
                cmd.Parameters("@Donvi").Value = dto.Donvi
                cmd.Parameters("@Quyen").Value = dto.Quyen
                cmd.Parameters("@CardNo").Value = dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = dto.Gioitinh
                cmd.Parameters("@Diachi").Value = dto.Diachi
                cmd.Parameters("@CMND").Value = dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = dto.Hinh
                cmd.Parameters("@Trangthai").Value = dto.Trangthai
                cmd.Parameters("@Ghichu").Value = dto.Ghichu
                cmd.Parameters("@MaNV").Value = dto.MaNV
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set NVSP= @NVSP , TenNV= @TenNV , TenHT= @TenHT , Chucvu= @Chucvu , Donvi= @Donvi , Quyen= @Quyen , CardNo= @CardNo , Ngaysinh= @Ngaysinh , Gioitinh= @Gioitinh , Diachi= @Diachi , CMND= @CMND , Ngayvaolam= @Ngayvaolam , Hinh= @Hinh , Trangthai= @Trangthai , Ghichu= @Ghichu where MaNV= @MaNV"
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@NVSP", SqlDbType.NVarChar)
                cmd.Parameters.Add("@TenNV", SqlDbType.NVarChar)
                cmd.Parameters.Add("@TenHT", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Chucvu", SqlDbType.Int)
                cmd.Parameters.Add("@Donvi", SqlDbType.Int)
                cmd.Parameters.Add("@Quyen", SqlDbType.Int)
                cmd.Parameters.Add("@CardNo", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Ngaysinh", SqlDbType.DateTime)
                cmd.Parameters.Add("@Gioitinh", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Diachi", SqlDbType.NVarChar)
                cmd.Parameters.Add("@CMND", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Ngayvaolam", SqlDbType.DateTime)
                cmd.Parameters.Add("@Hinh", SqlDbType.NVarChar)
                cmd.Parameters.Add("@Trangthai", SqlDbType.Int)
                cmd.Parameters.Add("@Ghichu", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@NVSP").Value = dto.NVSP
                cmd.Parameters("@TenNV").Value = dto.TenNV
                cmd.Parameters("@TenHT").Value = dto.TenHT
                cmd.Parameters("@Chucvu").Value = dto.Chucvu
                cmd.Parameters("@Donvi").Value = dto.Donvi
                cmd.Parameters("@Quyen").Value = dto.Quyen
                cmd.Parameters("@CardNo").Value = dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = dto.Gioitinh
                cmd.Parameters("@Diachi").Value = dto.Diachi
                cmd.Parameters("@CMND").Value = dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = dto.Hinh
                cmd.Parameters("@Trangthai").Value = dto.Trangthai
                cmd.Parameters("@Ghichu").Value = dto.Ghichu
                cmd.Parameters("@MaNV").Value = dto.MaNV
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set NVSP= @NVSP , TenNV= @TenNV , TenHT= @TenHT , Chucvu= @Chucvu , Donvi= @Donvi , Quyen= @Quyen , CardNo= @CardNo , Ngaysinh= @Ngaysinh , Gioitinh= @Gioitinh , Diachi= @Diachi , CMND= @CMND , Ngayvaolam= @Ngayvaolam , Hinh= @Hinh , Trangthai= @Trangthai , Ghichu= @Ghichu where MaNV= @MaNV"
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.Parameters("@NVSP").Value = dto.NVSP
                cmd.Parameters("@TenNV").Value = dto.TenNV
                cmd.Parameters("@TenHT").Value = dto.TenHT
                cmd.Parameters("@Chucvu").Value = dto.Chucvu
                cmd.Parameters("@Donvi").Value = dto.Donvi
                cmd.Parameters("@Quyen").Value = dto.Quyen
                cmd.Parameters("@CardNo").Value = dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = dto.Gioitinh
                cmd.Parameters("@Diachi").Value = dto.Diachi
                cmd.Parameters("@CMND").Value = dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = dto.Hinh
                cmd.Parameters("@Trangthai").Value = dto.Trangthai
                cmd.Parameters("@Ghichu").Value = dto.Ghichu
                cmd.Parameters("@MaNV").Value = dto.MaNV
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set NVSP= @NVSP , TenNV= @TenNV , TenHT= @TenHT , Chucvu= @Chucvu , Donvi= @Donvi , Quyen= @Quyen , CardNo= @CardNo , Ngaysinh= @Ngaysinh , Gioitinh= @Gioitinh , Diachi= @Diachi , CMND= @CMND , Ngayvaolam= @Ngayvaolam , Hinh= @Hinh , Trangthai= @Trangthai , Ghichu= @Ghichu where MaNV= @MaNV"
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.Parameters("@NVSP").Value = dto.NVSP
                cmd.Parameters("@TenNV").Value = dto.TenNV
                cmd.Parameters("@TenHT").Value = dto.TenHT
                cmd.Parameters("@Chucvu").Value = dto.Chucvu
                cmd.Parameters("@Donvi").Value = dto.Donvi
                cmd.Parameters("@Quyen").Value = dto.Quyen
                cmd.Parameters("@CardNo").Value = dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = dto.Gioitinh
                cmd.Parameters("@Diachi").Value = dto.Diachi
                cmd.Parameters("@CMND").Value = dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = dto.Hinh
                cmd.Parameters("@Trangthai").Value = dto.Trangthai
                cmd.Parameters("@Ghichu").Value = dto.Ghichu
                cmd.Parameters("@MaNV").Value = dto.MaNV
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set NVSP= @NVSP , TenNV= @TenNV , TenHT= @TenHT , Chucvu= @Chucvu , Donvi= @Donvi , Quyen= @Quyen , CardNo= @CardNo , Ngaysinh= @Ngaysinh , Gioitinh= @Gioitinh , Diachi= @Diachi , CMND= @CMND , Ngayvaolam= @Ngayvaolam , Hinh= @Hinh , Trangthai= @Trangthai , Ghichu= @Ghichu where MaNV= @MaNV"
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.Parameters.Add("@NVSP", MySqlDbType.String)
                cmd.Parameters.Add("@TenNV", MySqlDbType.String)
                cmd.Parameters.Add("@TenHT", MySqlDbType.String)
                cmd.Parameters.Add("@Chucvu", MySqlDbType.Int32)
                cmd.Parameters.Add("@Donvi", MySqlDbType.Int32)
                cmd.Parameters.Add("@Quyen", MySqlDbType.Int32)
                cmd.Parameters.Add("@CardNo", MySqlDbType.String)
                cmd.Parameters.Add("@Ngaysinh", MySqlDbType.DateTime)
                cmd.Parameters.Add("@Gioitinh", MySqlDbType.String)
                cmd.Parameters.Add("@Diachi", MySqlDbType.String)
                cmd.Parameters.Add("@CMND", MySqlDbType.String)
                cmd.Parameters.Add("@Ngayvaolam", MySqlDbType.DateTime)
                cmd.Parameters.Add("@Hinh", MySqlDbType.String)
                cmd.Parameters.Add("@Trangthai", MySqlDbType.Int32)
                cmd.Parameters.Add("@Ghichu", MySqlDbType.String)
                cmd.Parameters.Add("@MaNV", MySqlDbType.Int32)
                cmd.Parameters("@NVSP").Value = dto.NVSP
                cmd.Parameters("@TenNV").Value = dto.TenNV
                cmd.Parameters("@TenHT").Value = dto.TenHT
                cmd.Parameters("@Chucvu").Value = dto.Chucvu
                cmd.Parameters("@Donvi").Value = dto.Donvi
                cmd.Parameters("@Quyen").Value = dto.Quyen
                cmd.Parameters("@CardNo").Value = dto.CardNo
                cmd.Parameters("@Ngaysinh").Value = dto.Ngaysinh
                cmd.Parameters("@Gioitinh").Value = dto.Gioitinh
                cmd.Parameters("@Diachi").Value = dto.Diachi
                cmd.Parameters("@CMND").Value = dto.CMND
                cmd.Parameters("@Ngayvaolam").Value = dto.Ngayvaolam
                cmd.Parameters("@Hinh").Value = dto.Hinh
                cmd.Parameters("@Trangthai").Value = dto.Trangthai
                cmd.Parameters("@Ghichu").Value = dto.Ghichu
                cmd.Parameters("@MaNV").Value = dto.MaNV
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaNVSP(ByVal NVSP As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set NVSP = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@NVSP", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@NVSP").Value = NVSP
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set NVSP = @NVSP  where MaNV= @MaNV "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@NVSP", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@NVSP").Value = NVSP
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set NVSP =" & NVSP & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set NVSP =" & NVSP & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set NVSP =" & NVSP & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaTenNV(ByVal TenNV As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set TenNV = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@TenNV", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@TenNV").Value = TenNV
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set TenNV = @TenNV  where MaNV= @MaNV "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@TenNV", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@TenNV").Value = TenNV
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set TenNV =" & TenNV & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set TenNV =" & TenNV & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set TenNV =" & TenNV & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaTenHT(ByVal TenHT As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set TenHT = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@TenHT", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@TenHT").Value = TenHT
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set TenHT = @TenHT  where MaNV= @MaNV "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@TenHT", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@TenHT").Value = TenHT
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set TenHT =" & TenHT & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set TenHT =" & TenHT & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set TenHT =" & TenHT & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaChucvu(ByVal Chucvu As System.Int32, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Chucvu = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Chucvu", OleDbType.Integer)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Chucvu").Value = Chucvu
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Chucvu = @Chucvu  where MaNV= @MaNV "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Chucvu", SqlDbType.Int)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Chucvu").Value = Chucvu
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Chucvu =" & Chucvu & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Chucvu =" & Chucvu & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Chucvu =" & Chucvu & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaDonvi(ByVal Donvi As System.Int32, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Donvi = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Donvi", OleDbType.Integer)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Donvi").Value = Donvi
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Donvi = @Donvi  where MaNV= @MaNV "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Donvi", SqlDbType.Int)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Donvi").Value = Donvi
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Donvi =" & Donvi & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Donvi =" & Donvi & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Donvi =" & Donvi & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaQuyen(ByVal Quyen As System.Int32, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Quyen = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Quyen", OleDbType.Integer)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Quyen").Value = Quyen
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Quyen = @Quyen  where MaNV= @MaNV "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Quyen", SqlDbType.Int)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Quyen").Value = Quyen
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Quyen =" & Quyen & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Quyen =" & Quyen & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Quyen =" & Quyen & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaCardNo(ByVal CardNo As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set CardNo = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@CardNo", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@CardNo").Value = CardNo
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set CardNo = @CardNo  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@CardNo", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@CardNo").Value = CardNo
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set CardNo =" & CardNo & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set CardNo =" & CardNo & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set CardNo =" & CardNo & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaNgaysinh(ByVal Ngaysinh As System.DateTime, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Ngaysinh = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Ngaysinh", OleDbType.Date)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Ngaysinh").Value = Ngaysinh
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Ngaysinh = @Ngaysinh  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Ngaysinh", SqlDbType.DateTime)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Ngaysinh").Value = Ngaysinh
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Ngaysinh =" & Ngaysinh & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Ngaysinh =" & Ngaysinh & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Ngaysinh =" & Ngaysinh & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaGioitinh(ByVal Gioitinh As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Gioitinh = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Gioitinh", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Gioitinh").Value = Gioitinh
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Gioitinh = @Gioitinh  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Gioitinh", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Gioitinh").Value = Gioitinh
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Gioitinh =" & Gioitinh & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Gioitinh =" & Gioitinh & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Gioitinh =" & Gioitinh & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaDiachi(ByVal Diachi As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Diachi = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Diachi", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Diachi").Value = Diachi
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Diachi = @Diachi  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Diachi", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Diachi").Value = Diachi
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Diachi =" & Diachi & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Diachi =" & Diachi & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Diachi =" & Diachi & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaCMND(ByVal CMND As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set CMND = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@CMND", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@CMND").Value = CMND
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set CMND = @CMND  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@CMND", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@CMND").Value = CMND
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set CMND =" & CMND & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set CMND =" & CMND & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set CMND =" & CMND & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaNgayvaolam(ByVal Ngayvaolam As System.DateTime, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Ngayvaolam = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Ngayvaolam", OleDbType.Date)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Ngayvaolam").Value = Ngayvaolam
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Ngayvaolam = @Ngayvaolam  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Ngayvaolam", SqlDbType.DateTime)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Ngayvaolam").Value = Ngayvaolam
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Ngayvaolam =" & Ngayvaolam & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Ngayvaolam =" & Ngayvaolam & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Ngayvaolam =" & Ngayvaolam & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaHinh(ByVal Hinh As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Hinh = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Hinh", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Hinh").Value = Hinh
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Hinh = @Hinh  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Hinh", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Hinh").Value = Hinh
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Hinh =" & Hinh & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Hinh =" & Hinh & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Hinh =" & Hinh & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaTrangthai(ByVal Trangthai As System.Int32, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Trangthai = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Trangthai", OleDbType.Integer)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Trangthai").Value = Trangthai
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Trangthai = @Trangthai  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Trangthai", SqlDbType.Int)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Trangthai").Value = Trangthai
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Trangthai =" & Trangthai & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Trangthai =" & Trangthai & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Trangthai =" & Trangthai & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub SuaGhichu(ByVal Ghichu As System.String, ByVal ma As String)
        Dim strSQL As String
        Moketnoi()
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
                strSQL = "Update Nhanvien Set Ghichu = ?  where MaNV= ? "
                Dim cmd As New OleDbCommand(strSQL, Ket_noi_Access)
                cmd.Parameters.Add("@Ghichu", OleDbType.VarWChar)
                cmd.Parameters.Add("@MaNV", OleDbType.Integer)
                cmd.Parameters("@Ghichu").Value = Ghichu
                cmd.Parameters("@MaNV").Value = ma
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strSQL = "Update Nhanvien Set Ghichu = @Ghichu  where MaNV= ? "
                Dim cmd As New SqlCommand(strSQL, Ket_noi_Sql)
                cmd.Parameters.Add("@Ghichu", SqlDbType.NVarChar)
                cmd.Parameters.Add("@MaNV", SqlDbType.Int)
                cmd.Parameters("@Ghichu").Value = Ghichu
                cmd.Parameters("@MaNV").Value = ma
            Case Class_KieuDL.SqlCe
                strSQL = "Update Nhanvien Set Ghichu =" & Ghichu & "  where MaNV=" & ma & ""
                Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.Oracle
                strSQL = "Update Nhanvien Set Ghichu =" & Ghichu & "  where MaNV=" & ma & ""
                Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
                cmd.ExecuteNonQuery()
            Case Class_KieuDL.MySql
                strSQL = "Update Nhanvien Set Ghichu =" & Ghichu & "  where MaNV=" & ma & ""
                Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
                cmd.ExecuteNonQuery()
        End Select
        Ngatketnoi()
    End Sub
    Public Sub layBang()
        Chuoi_SQL = " Select * from Nhanvien"
        Doc_bang()
    End Sub
    Public Sub layBangTheoMaNV(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "MaNV=" & ARRAY1.Item(I) & ""
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoMaNV(ByVal MaNV As System.Int32)
        Chuoi_SQL = " Select * from Nhanvien where  MaNV = " & MaNV & ""
        Doc_bang()
    End Sub
    Public Sub XOABangTheoMaNV(ByVal MaNV As System.Int32)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where MaNV=" & MaNV & ""
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoNVSP(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "NVSP='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoNVSP_like(ByVal NVSP As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  NVSP  like '%" & NVSP & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoNVSP(ByVal NVSP As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  NVSP = '" & NVSP & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoNVSP(ByVal NVSP As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where NVSP='" & NVSP & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoTenNV(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "TenNV='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoTenNV_like(ByVal TenNV As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  TenNV  like '%" & TenNV & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoTenNV(ByVal TenNV As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  TenNV = '" & TenNV & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoTenNV(ByVal TenNV As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where TenNV='" & TenNV & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoTenHT(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "TenHT='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoTenHT_like(ByVal TenHT As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  TenHT  like '%" & TenHT & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoTenHT(ByVal TenHT As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  TenHT = '" & TenHT & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoTenHT(ByVal TenHT As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where TenHT='" & TenHT & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoChucvu(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Chucvu=" & ARRAY1.Item(I) & ""
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoChucvu(ByVal Chucvu As System.Int32)
        Chuoi_SQL = " Select * from Nhanvien where  Chucvu = " & Chucvu & ""
        Doc_bang()
    End Sub
    Public Sub XOABangTheoChucvu(ByVal Chucvu As System.Int32)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Chucvu=" & Chucvu & ""
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoDonvi(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Donvi=" & ARRAY1.Item(I) & ""
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoDonvi(ByVal Donvi As System.Int32)
        Chuoi_SQL = " Select * from Nhanvien where  Donvi = " & Donvi & ""
        Doc_bang()
    End Sub
    Public Sub XOABangTheoDonvi(ByVal Donvi As System.Int32)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Donvi=" & Donvi & ""
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoQuyen(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Quyen=" & ARRAY1.Item(I) & ""
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoQuyen(ByVal Quyen As System.Int32)
        Chuoi_SQL = " Select * from Nhanvien where  Quyen = " & Quyen & ""
        Doc_bang()
    End Sub
    Public Sub XOABangTheoQuyen(ByVal Quyen As System.Int32)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Quyen=" & Quyen & ""
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoCardNo(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "CardNo='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoCardNo_like(ByVal CardNo As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  CardNo  like '%" & CardNo & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoCardNo(ByVal CardNo As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  CardNo = '" & CardNo & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoCardNo(ByVal CardNo As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where CardNo='" & CardNo & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoNgaysinh(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Ngaysinh='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoNgaysinh(ByVal Ngaysinh As System.DateTime)
        Chuoi_SQL = " Select * from Nhanvien where  Ngaysinh = @Ngay"
        Doc_bang_Dk_ngay(Ngaysinh)
    End Sub
    Public Sub layBangTheoNgaysinh(ByVal Ngaysinh1 As System.DateTime, ByVal Ngaysinh2 As System.DateTime)
        Chuoi_SQL = " Select * from Nhanvien where  Ngaysinh >= @Ngay and Ngaysinh <= @denNgay ORDER BY Ngaysinh"
        Doc_bang_Dk_ngay(Ngaysinh1, Ngaysinh2)
    End Sub
    Public Sub XOABangTheoNgaysinh(ByVal Ngaysinh As System.DateTime)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Ngaysinh='" & Ngaysinh & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoGioitinh(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Gioitinh='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoGioitinh_like(ByVal Gioitinh As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Gioitinh  like '%" & Gioitinh & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoGioitinh(ByVal Gioitinh As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Gioitinh = '" & Gioitinh & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoGioitinh(ByVal Gioitinh As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Gioitinh='" & Gioitinh & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoDiachi(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Diachi='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoDiachi_like(ByVal Diachi As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Diachi  like '%" & Diachi & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoDiachi(ByVal Diachi As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Diachi = '" & Diachi & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoDiachi(ByVal Diachi As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Diachi='" & Diachi & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoCMND(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "CMND='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoCMND_like(ByVal CMND As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  CMND  like '%" & CMND & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoCMND(ByVal CMND As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  CMND = '" & CMND & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoCMND(ByVal CMND As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where CMND='" & CMND & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoNgayvaolam(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Ngayvaolam='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoNgayvaolam(ByVal Ngayvaolam As System.DateTime)
        Chuoi_SQL = " Select * from Nhanvien where  Ngayvaolam = @Ngay"
        Doc_bang_Dk_ngay(Ngayvaolam)
    End Sub
    Public Sub layBangTheoNgayvaolam(ByVal Ngayvaolam1 As System.DateTime, ByVal Ngayvaolam2 As System.DateTime)
        Chuoi_SQL = " Select * from Nhanvien where  Ngayvaolam >= @Ngay and Ngayvaolam <= @denNgay ORDER BY Ngayvaolam"
        Doc_bang_Dk_ngay(Ngayvaolam1, Ngayvaolam2)
    End Sub
    Public Sub XOABangTheoNgayvaolam(ByVal Ngayvaolam As System.DateTime)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Ngayvaolam='" & Ngayvaolam & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoHinh(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Hinh='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoHinh_like(ByVal Hinh As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Hinh  like '%" & Hinh & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoHinh(ByVal Hinh As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Hinh = '" & Hinh & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoHinh(ByVal Hinh As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Hinh='" & Hinh & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoTrangthai(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Trangthai=" & ARRAY1.Item(I) & ""
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoTrangthai(ByVal Trangthai As System.Int32)
        Chuoi_SQL = " Select * from Nhanvien where  Trangthai = " & Trangthai & ""
        Doc_bang()
    End Sub
    Public Sub XOABangTheoTrangthai(ByVal Trangthai As System.Int32)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Trangthai=" & Trangthai & ""
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangTheoGhichu(ByVal ARRAY1 As ArrayList)
        Dim DK As String = ""
        If ARRAY1.Count > 0 Then
            For I As Integer = 0 To ARRAY1.Count - 1
                DK = DK & IIf(DK <> "", " OR ", "") & "Ghichu='" & ARRAY1.Item(I) & "'"
            Next
        End If
        If DK <> "" Then DK = " WHERE " & DK
        Chuoi_SQL = " Select * from Nhanvien" & DK
        Doc_bang()
    End Sub
    Public Sub layBangTheoGhichu_like(ByVal Ghichu As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Ghichu  like '%" & Ghichu & "%'"
        Doc_bang()
    End Sub
    Public Sub layBangTheoGhichu(ByVal Ghichu As System.String)
        Chuoi_SQL = " Select * from Nhanvien where  Ghichu = '" & Ghichu & "'"
        Doc_bang()
    End Sub
    Public Sub XOABangTheoGhichu(ByVal Ghichu As System.String)
        Dim strsql As String
        strsql = "Delete From Nhanvien Where Ghichu='" & Ghichu & "'"
        Thuc_hien_lenh(strsql)
    End Sub
    Public Sub layBangNhieuTable()
        Chuoi_SQL = " Select MaNV ,NVSP ,TenNV ,TenHT ,Chucvu ,Donvi ,Quyen ,CardNo ,Ngaysinh ,Gioitinh ,Diachi ,CMND ,Ngayvaolam ,Hinh ,Trangthai ,Ghichu  from Nhanvien"
        Doc_bang()
    End Sub
    Public Sub TaoTable()
        Dim strsql As String
        strsql = ""
        Select Case Ketnoi.MsSql
            Case Class_KieuDL.Access
            Case Class_KieuDL.sql, Class_KieuDL.sqlExpress
                strsql = ""
            Case Class_KieuDL.SqlCe
                strsql = ""
            Case Class_KieuDL.Oracle
                strsql = ""
            Case Else
                strsql = ""
        End Select
        Thuc_hien_lenh(strsql)
    End Sub

#Region "Ham "
    Public Sub MaThem()
        Chuoi_SQL = "Select max(manv) from nhanvien"
        Doc_bang()
    End Sub
    'Public Sub layBangtableCodk(ByVal dk As System.String)
    '    Chuoi_SQL = " Select * from Nhanvien where  0=1 " & dk
    '    Doc_bang()
    'End Sub
    Public Sub LayBangTable()
        Chuoi_SQL = "SELECT Nhanvien.MaNV, Nhanvien.TenNV, Nhanvien.TenHT, chucvu.Chucvu, Donvi.TenDV, Nhanvien.CardNo, Nhanvien.Gioitinh, Nhanvien.Diachi, Nhanvien.CMND, Nhanvien.Ngayvaolam, Nhanvien.NVSP, Nhanvien.Quyen, Nhanvien.Ngaysinh FROM chucvu INNER JOIN (Donvi INNER JOIN Nhanvien ON Donvi.MaDV = Nhanvien.Donvi) ON chucvu.CVID = Nhanvien.Chucvu "
        Doc_bang()
    End Sub
    Public Sub LayBangTableCodk(ByVal dk As String)
        Chuoi_SQL = "SELECT Nhanvien.MaNV, Nhanvien.TenNV, Nhanvien.TenHT, chucvu.Chucvu, Donvi.TenDV, Nhanvien.CardNo, Nhanvien.Gioitinh, Nhanvien.Diachi, Nhanvien.CMND, Nhanvien.Ngayvaolam, Nhanvien.NVSP, Nhanvien.Quyen, Nhanvien.Ngaysinh FROM chucvu INNER JOIN (Donvi INNER JOIN Nhanvien ON Donvi.MaDV = Nhanvien.Donvi) ON chucvu.CVID = Nhanvien.Chucvu  where 0=1" & dk
        Doc_bang()
    End Sub

    Public Sub LayBangTabletheodonviCoLich(ByVal madv As Integer)
        Chuoi_SQL = "SELECT Nhanvien.MaNV, Nhanvien.TenNV, Nhanvien.TenHT, chucvu.Chucvu, Donvi.TenDV, Nhanvien.CardNo, Nhanvien.Gioitinh, Nhanvien.Diachi, Nhanvien.CMND, Nhanvien.Ngayvaolam, Nhanvien.NVSP, Nhanvien.Quyen, Nhanvien.Ngaysinh FROM chucvu INNER JOIN (Donvi INNER JOIN Nhanvien ON Donvi.MaDV = Nhanvien.Donvi) ON chucvu.CVID = Nhanvien.Chucvu,lichnv where  nhanvien.MaNV = lichnv.NVID and donvi=" & madv
        Doc_bang()
    End Sub
    Public Sub LayBangTabletheodonviKhongCoLich(ByVal madv As Integer)
        Chuoi_SQL = "SELECT Nhanvien.MaNV, Nhanvien.TenNV, Nhanvien.TenHT, chucvu.Chucvu, Donvi.TenDV, Nhanvien.CardNo, Nhanvien.Gioitinh, Nhanvien.Diachi, Nhanvien.CMND, Nhanvien.Ngayvaolam, Nhanvien.NVSP, Nhanvien.Quyen, Nhanvien.Ngaysinh FROM chucvu INNER JOIN (Donvi INNER JOIN Nhanvien ON Donvi.MaDV = Nhanvien.Donvi) ON chucvu.CVID = Nhanvien.Chucvu WHERE Nhanvien.Donvi=" & madv & " and  manv not in (select NVID from lichnv)"
        Doc_bang()
    End Sub
    Public Sub LayBangTabletheodonvi(ByVal madv As Integer)
        Chuoi_SQL = "SELECT Nhanvien.MaNV, Nhanvien.TenNV, Nhanvien.TenHT, chucvu.Chucvu, Donvi.TenDV, Nhanvien.CardNo, Nhanvien.Gioitinh, Nhanvien.Diachi, Nhanvien.CMND, Nhanvien.Ngayvaolam, Nhanvien.NVSP, Nhanvien.Quyen, Nhanvien.Ngaysinh FROM chucvu INNER JOIN (Donvi INNER JOIN Nhanvien ON Donvi.MaDV = Nhanvien.Donvi) ON chucvu.CVID = Nhanvien.Chucvu where(donvi = " & madv & ")"
        Doc_bang()
    End Sub
    Public Sub LayBangTabletheodonviBT(ByVal madv As Integer)
        Chuoi_SQL = "SELECT Nhanvien.* FROM Nhanvien where donvi = " & madv
        Doc_bang()
    End Sub
    Public Sub LocNhanVienUSB(ByVal madv As Integer)
        Chuoi_SQL = "SELECT Nhanvien.MaNV, Nhanvien.NVSP, Nhanvien.TenNV, Nhanvien.TenHT  , Nhanvien.Quyen , Nhanvien.CardNo FROM chucvu INNER JOIN (Donvi INNER JOIN Nhanvien ON Donvi.MaDV = Nhanvien.Donvi) ON chucvu.CVID = Nhanvien.Chucvu where(donvi = " & madv & ")"
        Doc_bang()
    End Sub

    Public Sub LocNhanVienUSBAll()
        Chuoi_SQL = "SELECT Nhanvien.MaNV, Nhanvien.NVSP, Nhanvien.TenNV, Nhanvien.TenHT  , Nhanvien.Quyen , Nhanvien.CardNo FROM chucvu INNER JOIN (Donvi INNER JOIN Nhanvien ON Donvi.MaDV = Nhanvien.Donvi) ON chucvu.CVID = Nhanvien.Chucvu "
        Doc_bang()
    End Sub


    Public Sub LayBangTabletheodonviDemo(ByVal madv As Integer)
        Chuoi_SQL = "SELECT Nhanvien.MaNV,Nhanvien.TenHT,CardNo,Nhanvien.Quyen FROM Nhanvien where(donvi = " & madv & ")"
        Doc_bang()
    End Sub
    Public Sub LayBangTabletheoCMND(ByVal cmnd As String)
        Chuoi_SQL = "SELECT * FROM Nhanvien where cmnd = '" & cmnd & "'"
        Doc_bang()
    End Sub
    Public Sub LayBangTabletheochucvu(ByVal macv As Integer)
        Chuoi_SQL = "SELECT * FROM Nhanvien where chucvu = " & macv
        Doc_bang()
    End Sub
#End Region
End Class

